// pages/companymanagement/companymanagement.js
import user from '../../utils/user.js'
import {
    userexitcompanyapi,
    getlogoutcompanyinfoapi
} from '../api/personalMsg.js'
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        dissolvemsg: {},
        msg: {},
        isUp: false,
        isUptwo: false,
        uptowmsg: '',
        issuper: true,
        isquitok: true,
    },
    quit() {
        console.log(this.data.msg.isselect, '退出')
        userexitcompanyapi({
            companyId: this.data.msg.companyid
        }).then((res) => {
            console.log(res, 'hifsugdihug')
            if (res) {
                this.setData({
                    isUp: false,
                    isUptwo: true,
                    uptowmsg: res
                })
            } else {
                if (this.data.msg.isselect === 'true') {
                    user.init()
                    app.toast('退出成功，正在为您跳转到首页！')
                    setTimeout(() => {
                        wx.reLaunch({
                            url: '/pages/index/index'
                        })
                    }, 1000)
                } else {
                    wx.reLaunch({
                        url: '/pages/personalmsg/personalmsg',
                    })
                }
            }
        })
    },
    dissolve() {
        console.log('解散')
        wx.navigateTo({
            url: '/pages/proposalfordissolution/proposalfordissolution?companyid=' + this.data.msg.companyid + '&isselect=' + this.data.msg.isselect,
        })
    },
    close() {
        this.setData({
            isUp: false
        })
    },
    closetwo() {
        this.setData({
            isUptwo: false
        })
    },
    async checkout() {
        if (this.data.msg.isadmin === '2') {
            let res = await getlogoutcompanyinfoapi({
                companyId: this.data.msg.companyid
            })
            console.log(res)
            this.setData({
                dissolvemsg: res
            })
        }
        this.setData({
            isUp: true
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        console.log(options)
        this.setData({
            issuper: options.isadmin === '2' ? true : false,
            msg: options
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})